package com.mrx.commons.util.redis;

import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;

import java.util.concurrent.TimeUnit;

@Data
@Accessors(chain = true)
@RequiredArgsConstructor(staticName = "of")
public class ValueWrapper {

    private final Object obj;
    private long timeout = 30;
    private TimeUnit unit = TimeUnit.DAYS;
    private long createTime = System.currentTimeMillis();

    public boolean isExpired() {
        return createTime + unit.toMillis(timeout) <= System.currentTimeMillis();
    }

}
